package common

import (
    "time"
    "strings"
    "strconv"
)

type Node string

func (n Node) IsValid() bool {
    s := strings.Split(string(n), ":")
    if len(s) != 2 {
        return false
    }
    _, err := strconv.Atoi(s[1])
    return err == nil //node==ip or host :port
}

func (n Node) Addr(addr string) string {
    s := strings.Split(string(n), ":")
    return addr + ":" + s[1]
}

func NowNanosecond() uint64 {
    return uint64(time.Now().UnixNano())
}
func NowMillisecond() uint64 {
    return uint64(time.Now().UnixNano() / 1000 / 1000)
}
